﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

namespace ZGameFramework.UI
{
    public class BubbleCellScale : BubbelCellBase
    {
        [HideInInspector]public Vector3 from = Vector3.zero;
        [HideInInspector]public Vector3 to = Vector3.one;
        

        private void OnEnable()
        {
            transform.localScale = from;
        }


        public override void StartFadeIn()
        {
            transform.localScale = from;
            transform.DOScale(to, duration).SetEase( Ease.OutBack);
           // base.StartFadeIn();
        }

        public override void StartFadeOut()
        {
            transform.localScale = to;
            transform.DOScale(from, duration).SetEase(Ease.InBack);
            // base.StartFadeIn();
        }


        //private UITweener _tween;
        //public TweenScale tween
        //{
        //    get
        //    {
        //        if (null == _tween) { _tween = this.gameObject.GetComponent<TweenScale>(); }
        //        if (null == _tween) { _tween = this.gameObject.AddComponent<TweenScale>(); _tween.animationCurve = animationCurve; }

        //        return _tween as TweenScale;
        //    }
        //}

        //public override void StartFadeIn()
        //{

        //    tween.duration = duration;
        //    tween.from = from;
        //    tween.to = to;

        //    if (AnimationOrTween.Direction.Forward == tween.direction)
        //    {
        //        tween.ResetToBeginning();
        //        tween.PlayForward();
        //    }
        //    else if (AnimationOrTween.Direction.Reverse == tween.direction)
        //    {
        //        tween.tweenFactor = 0;
        //        tween.PlayForward();
        //    }
        //}

        //public override void StartFadeOut()
        //{
        //    tween.duration = duration;
        //    tween.from = from;
        //    tween.to = to;

        //    if (AnimationOrTween.Direction.Forward == tween.direction)
        //    {
        //        tween.tweenFactor = 1;
        //        tween.PlayReverse();
        //    }
        //    else if (AnimationOrTween.Direction.Reverse == tween.direction)
        //    {
        //        tween.ResetToBeginning();
        //        tween.PlayReverse();
        //    }
        //}

    }
}
